

export default {
  namespaced: true,
  state: {
    liveRoomId: undefined,
    teacherId: undefined,
    title: undefined,
    teacherName: undefined,
    content: undefined,
  },
  mutations: {
    UPDATE_LIVE_ROOM_ID(state, liveRoomId) {
      return state.liveRoomId = liveRoomId;
    },
    UPDATE_TEACHER_ID(state, teacherId) {
      return state.teacherId = teacherId;
    },
    UPDATE_TITLE(state, title) {
      return state.title = title;
    },
    UPDATE_TEACHER_NAME(state, teacherName) {
      return state.teacherName = teacherName;
    },
    UPDATE_CONTENT(state, content) {
      return state.content = content;
    }
  },
  actions: {
    setLiveRoom({
      commit
    }, data) {
      return new Promise((resolve, reject) => {
        commit("UPDATE_LIVE_ROOM_ID", data.id);
        commit("UPDATE_TEACHER_ID", data.teacherId);
        commit("UPDATE_TITLE", data.title);
        commit("UPDATE_TEACHER_NAME", data.teacherName);
        commit("UPDATE_CONTENT", data.content);
        resolve();
      })
    },
  },

  getters: {
    liveRoomId(state) {
      return state.liveRoomId;
    },
    teacherId(state) {
      return state.teacherId;
    },
    title(state) {
      return state.title;
    },
    teacherName(state) {
      return state.teacherName;
    },
    content(state) {
      return state.content;
    }
  }

}